from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from config import config
from flask_session import Session
from flask_wtf import CSRFProtect

db = SQLAlchemy()


def create_app(config_name):

    app = Flask(__name__)

    app.config.from_object(config[config_name])

    db.init_app(app)

    Session(app)

    CSRFProtect(app)

    return app
